<template>
<!--  头部-->
  <div style="padding: 20px 20px 0px 20px">
  <div>
      <span style="font-size: 35px">店铺审核</span>
  </div>
  <el-table
      :data="AuditStoreData"
      style="width: 100%;"
      :show-overflow-tooltip="false"
      :border="true"
  >
    <el-table-column
        prop="uname" label="用户" :show-overflow-tooltip="true">
    </el-table-column>

    <el-table-column prop="name" label="名称" :show-overflow-tooltip="true"></el-table-column>

    <el-table-column prop="contacts" label="联系人" :show-overflow-tooltip="true"></el-table-column>

    <el-table-column prop="mobile" label="电话" :show-overflow-tooltip="true"></el-table-column>
    <el-table-column prop="saddress" label="区域" :show-overflow-tooltip="true"></el-table-column>
    <el-table-column prop="site" label="详细地址" :show-overflow-tooltip="true"></el-table-column>

    <el-table-column  label="店铺图片">
      <template slot-scope="scope">
        <el-image
            style="width: 75px; height: 75px"
            :src="scope.row.img"
            :preview-src-list="imgs(scope.row.img)"
        >
        </el-image>

      </template>
    </el-table-column>

    <el-table-column  label="图片列表" >
      <template slot-scope="scope">
      <el-image
          style="width: 75px; height: 75px"
          :src="listImg(scope.row)[0]"
          :preview-src-list="listImg(scope.row)">
      </el-image>
      </template>
    </el-table-column>

    <el-table-column prop="level" label="等级" :show-overflow-tooltip="true"></el-table-column>

    <el-table-column prop="startTime" label="开店时间" :show-overflow-tooltip="true"></el-table-column>
    <el-table-column prop="endTime" label="关店时间" :show-overflow-tooltip="true"></el-table-column>
    <el-table-column prop="transportFee" label="运费" :show-overflow-tooltip="true"></el-table-column>
    <el-table-column prop="status" label="状态" :show-overflow-tooltip="true" :formatter="status">

    </el-table-column>

    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
            size="mini"
            @click="pass(scope.$index, scope.row)">通过</el-button>
        <el-button
            size="mini"
            @click="reject(scope.$index, scope.row)">驳回</el-button>
      </template>
    </el-table-column>
  </el-table>
  </div>

</template>

<script>
import as from "@/axios/axios";

export default {
  name: "Audit",
  created() {
    this.getAudit()
  },
  data(){
    return{
      AuditStoreData:[],
      storePage:{total:1,pages:1,size:1000},
    }
  },
  methods:{
    //查询审核店铺
    getAudit(){
      as.post("/store/communityGetName",{
        status:0,
        current:this.storePage.pages,
        size:this.storePage.size,}).
      then((res)=>{
        console.log("$",res)
        this.AuditStoreData = res.data.data.records
      })
    },
    //审核店铺通过
    pass(index,row){
      row.status = 1
      as.post("/store/alter",row).then((res)=>{
        this.$message({
          message: "通过",
          type: 'success'
        })
        this.getAudit()
      })

    },
    //审核店铺驳回
    reject(index,row){
      row.status = -3
      as.post("/store/alter",row).then((res)=>{
        this.$message("驳回");
        this.getAudit()
      })
    },
    //店铺状态
    status(row, column, cellValue, index){
      if(cellValue==1){
        return "正常营业"
      }else if(cellValue==0){
        return "店铺申请中"
      }else  if(cellValue == -3){
        return "店铺申请被驳回"
      }else if(cellValue == -1){
        return "店铺休息中"
      }else if(cellValue == -2){
        return "店铺关闭"
      }else {
        return ""
      }
    },
    listImg(row){
      // let s = row.imglist
      // s= s.replace("[","")
      // s= s.replace("]","")
      // s= s.replace(/\"/g, '')
      // let ss = s.split(",")

      return eval(row.imglist)
    },
    imgs(img){
      return [img]
    }
  }
}
</script>

<style scoped>


</style>